﻿BEGIN TRY
	BEGIN TRAN

	MERGE [dbo].[StatementType] AS TGT 
	USING
	(
		SELECT 1, 'Insert, Update and Delete' UNION ALL
		SELECT 2, 'Merge'
	) AS SRC ([StatementTypeId], [StatementTypeName])
	ON TGT.[StatementTypeId] = SRC.[StatementTypeId]  

	WHEN MATCHED THEN   
	UPDATE SET
		[StatementTypeName] = SRC.[StatementTypeName]
	WHEN NOT MATCHED BY TARGET THEN  
		INSERT ([StatementTypeId], [StatementTypeName])
		VALUES (SRC.[StatementTypeId], SRC.[StatementTypeName])

	WHEN NOT MATCHED BY SOURCE THEN  
		DELETE;

	COMMIT TRAN;
END TRY
BEGIN CATCH
	ROLLBACK TRAN;
END CATCH
